package control.elements;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class JavaPopBox extends JFrame {

	private String comment;
	
	public JavaPopBox() {
		super();
		createButton();
	}
	
	public void createButton(){
		JButton b1 = new JButton("Leave a Comment");
		b1.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent the_event) {
		try{
			comment = JOptionPane.showInputDialog(null, 
					"Enter your comment:");
			
			
		} catch (final IllegalArgumentException e) {
			
			JOptionPane.showMessageDialog(null, e.getMessage());
		}   
        }	
	});
		add(b1);
	}
	
	public String getComment() {
		return comment;
	}
	/**
	 * Starts the Gui.
	 */
	public void start() {
		setResizable(false);
		setPreferredSize(new Dimension(200, 100));
		pack();
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);	
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		JavaPopBox testBox = new JavaPopBox();
		testBox.start();
		
	}

}
